var t = getApp();

Page({
    data: {
        list: [],
        info: [],
        record_status: 0,
        other: !1,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        }), wx.setNavigationBarTitle({
            title: "见点奖励"
        }), t.other && this.setData({
            other: "other" == t.other
        }), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    tapchange: function(t) {
        this.init();
        var a = t.detail.index;
        this.setData({
            record_status: a
        }), this.getData();
    },
    init: function() {
        this.setData({
            isLoadMore: !0,
            page: 1,
            total_page: 0,
            list: []
        });
    },
    getData: function() {
        var a = this;
        wx.showLoading({
            title: "加载中"
        });
        var e = "plugin.jyk-find-point.frontend.controllers.rewards.index";
        this.data.other && (e = "plugin.jyk-find-point.frontend.controllers.others.index"), 
        t._getNetWork({
            url: t.getNetAddresss(e),
            data: {
                page: this.data.page,
                record_status: this.data.record_status
            },
            success: function(t) {
                if (wx.hideLoading({
                    success: function(t) {}
                }), 1 == t.data.result) {
                    var e = t.data.data;
                    a.setData({
                        isLoadMore: !0,
                        total_page: e.list.last_page,
                        info: e.info,
                        list: e.list.data
                    }), a.data.total_page || (a.data.total_page = 0), a.data.other || wx.setNavigationBarTitle({
                        title: e.info.name
                    });
                } else a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getMoreData: function() {
        var a = this;
        wx.showLoading({
            title: "加载中"
        });
        var e = "plugin.jyk-find-point.frontend.controllers.rewards.index";
        if (this.data.other && (e = "plugin.jyk-find-point.frontend.controllers.others.index"), 
        this.data.page >= this.data.total_page) return this.setData({
            isLoadMore: !1
        }), void wx.hideLoading({
            success: function(t) {}
        });
        this.setData({
            page: this.data.page + 1
        }), t._getNetWork({
            url: t.getNetAddresss(e),
            data: {
                page: this.data.page,
                record_status: this.data.record_status
            },
            success: function(t) {
                if (wx.hideLoading({
                    success: function(t) {}
                }), 1 == t.data.result) {
                    var e = t.data.data;
                    a.setData({
                        isLoadMore: !0,
                        list: a.data.list.concat(e.list.data)
                    });
                } else a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                wx.hideLoading({
                    success: function(t) {}
                }), console.log(t);
            }
        });
    }
});